﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" import="java.sql.*"%>
<%@ page import="ookweb.Conn"%>
<%@ page import="ookweb.Data"%>
<%@ page import="ookweb.*"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/ookweb/";
String baseRootPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String currenturl = request.getRequestURI()+(request.getQueryString()==null?"":("?"+request.getQueryString()));
if (Str.sql_inj(currenturl)){
    response.sendRedirect(path+"/");
    return;
}
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>东方通用户注册</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="东方通,注册">
	<meta http-equiv="description" content="注册">

  <meta http-equiv="Content-Type" content="text/html; charset=utf8"><style type="text/css">
<!--
body,td,th {
	font-size: 12px;
	color: #666666; line-height:22px;
}
a {
	font-size: 12px;
}
p{ padding-top:2px; padding-bottom:2px; margin-top:2px; margin-bottom:2px;}
.line{ border-bottom:1px solid #CCCCCC;}
.input{ width:200px; border:1px solid #B4D6E7;}
.cmd{ border:1px solid #0099CC; background:#DAE8EF; color:#006699; padding-top:3px; padding-bottom:2px; padding-left:6px; padding-right:6px;}
.rline{ border-right:1px solid  #CCCCCC;}
-->
</style>
<script src="js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function CheckForm(){
	var iu, iuu, regArray=new Array("","???","???","???","???","???","???","???"+
	"!","@","#","$","%","^","&","*","(",")","-","+","=","|","'","[","]","???","~","`"+
	"!","<",">","???","???","???","???","???","??","??"); 
	var iu, iuu, regArray=new Array("","???","???","???","???","???","???","???"+
	"!","@","#","$","%","^","&","*","(",")","-","+","=","|","'","[","]","???","~","`"+
	"!","<",">","???","???","???","???","???","??","??"); 
	iuu=regArray.length;
	if (document.forms[0].code.value.length<4) {
		alert("请填写验证码.");
		document.forms[0].code.focus();
		return false;
	}
	
	iuu=regArray.length;
	
	for(iu=1;iu<=iuu;iu++){
		if (document.forms[0].username.value.indexOf(regArray[iu])!=-1){
			alert("用户名不能够包含字符：" + regArray[iu]);
			document.forms[0].username.focus();
			return false;
		}
	}
	if (document.forms[0].username.value.length==0) {
		alert("用户名不能够为空.");
		document.forms[0].username.focus();
		return false;
	}
	if (document.forms[0].username.value.length<4) {
		alert("用户名长度不少于4个字符.");
		document.forms[0].username.focus();
		return false;
	}
	if (document.forms[0].username.value.length>12) {
		alert("用户名长度不大于12个字符.");
		document.forms[0].username.focus();
		return false;
	}
	if (document.forms[0].username.value.indexOf(" ")!=-1){
		alert("用户名不能够包含空格");
		document.forms[0].username.focus();
		return false;
	}
	
	if (document.forms[0].password1.value.length==0) {
		alert("密码长度不能够为零");
		document.forms[0].password1.focus();
		return false;
	}
	if (document.forms[0].password1.value.length<6) {
		alert("密码长度不应该小于6.");
		document.forms[0].password1.focus();
		return false;
	}
	if (document.forms[0].password2.value.length==0) {
		alert("确认密码长度不能够等于零");
		document.forms[0].password2.focus();
		return false;
	}
	if (document.forms[0].password1.value != document.forms[0].password2.value) {
		alert("两次密码不一致.");
		document.forms[0].password1.focus();
		return false;
	}
	for(iu=1;iu<=iuu;iu++){
		if (document.forms[0].true_name.value.indexOf(regArray[iu])!=-1){
			alert("真实姓名不能够包含字符：" + regArray[iu]);
			document.forms[0].true_name.focus();
			return false;
		}
	}
	if (document.forms[0].true_name.value.length==0) {
		alert("真实姓名不能够为空.");
		document.forms[0].true_name.focus();
		return false;
	}
	if (document.forms[0].true_name.value.indexOf(" ")!=-1){
		alert("真实姓名不能够包含空格");
		document.forms[0].true_name.focus();
		return false;
	}
	if (document.forms[0].com_name.value.length==0) {
		alert("公司名称不能够为空.");
		document.forms[0].com_name.focus();
		return false;
	}
		if (document.forms[0].com_name.value.indexOf(" ")!=-1){
		alert("公司名称不能够包含空格");
		document.forms[0].com_name.focus();
		return false;
	}
	if (document.forms[0].addr.value.length==0) {
		alert("联系方式不能够为空.");
		document.forms[0].addr.focus();
		return false;
	}
		if (document.forms[0].addr.value.indexOf(" ")!=-1){
		alert("联系方式不能够包含空格");
		document.forms[0].addr.focus();
		return false;
	}
	if (document.forms[0].email.value.length==0) {
		alert("E_mail长度不能够等于零.");
		document.forms[0].email.focus();
		return false;
	}
	if (document.forms[0].email.value.length>0 && !document.forms[0].email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) ) {
		alert("请填写正确的E_mail地址");
		document.forms[0].email.focus();
		return false;
	}
	if (document.forms[0].question.value.length>20) {
		alert("密码提示问题长度不能够大于20.");
		document.forms[0].question.focus();
		return false;
	}
	if (document.forms[0].answer.value.length>20) {
		alert("密码问题答案长度不能够大于20.");
		document.forms[0].answer.focus();
		return false;
	}
	return true;
} 

function chkfrm(v){
 if(v=='t'){
   $("#frmq").submit();
 }else{
  window.location.reload();
 }
}
</script>
<%

String act=request.getParameter("reg");
if("start".equals(act)){

String dbuser = application.getInitParameter("dbuser");
String dbpass = application.getInitParameter("dbpass");
String dburl  = application.getInitParameter("dburl");
  Data data=new Data(dbuser,dbpass,dburl);
  String sql="";
  String username="",userpass="",truename="",company="",telephone="",email="",question="",answer="";
    username=request.getParameter("username");
	userpass=request.getParameter("password1");
	truename=request.getParameter("true_name");
	//company=request.getParameter("com_name");
	//telephone=request.getParameter("addr");
	email=request.getParameter("email");
	question=request.getParameter("question");
	answer=request.getParameter("answer");
	
	 java.text.SimpleDateFormat formatter=new java.text.SimpleDateFormat("yyyy-MM-dd");
         java.util.Date currentTime=new java.util.Date();
         String time=formatter.format(currentTime);
         String mysql=" web_member where username='"+username+"'";
         int nums=data.getRowCount(mysql); //总记录数
         if(nums>0){%>
         <script>alert('用户有重名');window.location.href="<%=basePath%>register.jsp?step=2";</script>
         <%
         }else{
  sql="insert into web_member(mid,username,userpass,truename,email,question,answer,addtime)VALUES(WEB_MEMBER_SEQ.nextval,";
  sql=sql+"'"+username+"','"+userpass+"','"+truename+"','"+email+"','"+question+"','"+answer+"',to_date('"+time+"','yyyy/mm/dd'))";
  int num=data.insert(sql);
 
  if(num>0){
        session.setAttribute("ookweb_user_username",username);
        session.setAttribute("ookweb_user_password",userpass);
        response.sendRedirect(path+"/index.jsp");
       %>
        <script>alert("你已成功注册");window.location.href="<%=baseRootPath%>index.jsp"</script>    
  <%} }
}

%>
</head>
  
<body>
  
  <div align="center">
  <table width="100" height="540" border="0" align="center" cellpadding="0" cellspacing="0" style=" background:url(images/regbj.gif) left repeat-y;">
    <tr>
      <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td><img src="images/regtop.gif" width="775" height="31" border="0" usemap="#Map3" ></td>
        </tr>
      </table>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td><a href="index.jsp"> <img src="images/reglogo.gif" width="254" height="32" style=" margin-left:40px;" border=0></a></td>
          </tr>
          <tr>
            <td align="right"><img src="images/regtitle.gif" width="225" height="36" style=" margin-right:40px;"></td>
          </tr>
          <tr>
            <td height="10" align="right" bgcolor="#A00E15"></td>
          </tr>
          <tr>

            <td height="30" align="right"><br><br></td>
          </tr>
        </table>
        <%
		String step=request.getParameter("step");
		if(step!=null){%>
        <form name="form1" id="frmq" method="post" action="register.jsp" onSubmit="return CheckForm();">
        <input name="reg" type="hidden" value="start" />
        
        <table width="100%" border="0" cellpadding="0" cellspacing="0" style=" background:url(images/regyybj.gif) left repeat-y;">
          <tr>
            <td height="47"><img src="images/regyy.gif" width="775" height="74"></td>
          </tr>
          <tr>
            <td height="356" valign="top">
             <table width="87%" align="center" cellpadding="4" cellspacing="1">
          <tbody>
            <tr height="28">
              <td width="34%" height="35" align="right" bgcolor="#FFFFFF" class="line rline"><strong>系统验证码</strong> :<br />
               请填写右边正确的验证码 </td>
              <td width="66%" height="35" bgcolor="#FFFFFF" class="line"><input name="code" style=" width:80px;" type="text" class="input" id="code" />
              <img src="yzm.jsp">
                * 必填项<span id="nameinfo"></span></td>
            </tr>
            <tr height="28">
              <td width="34%" height="35" align="right" bgcolor="#FFFFFF" class="line rline"><strong>用户名</strong> :<br />
                用户名长度范围：4-12   个字符!<br />
                用户名不能够含有空字符和非法字符! </td>
              <td width="66%" height="35" bgcolor="#FFFFFF" class="line"><input name="username" type="text" class="input" id="username" />
                * 必填项<span id="nameinfo"></span></td>
            </tr>
            <tr>
              <td width="34%" height="35" align="right" bgcolor="#FFFFFF" class="line rline"><strong>密码</strong> :<br />
                密码长度应该大于等于6小于20   !<br />
                请不要以空字符或非法字符作为密码!<br /></td>
              <td height="35" bgcolor="#FFFFFF" class="line"><input   name="password1"  type="password" class="input"  id="password1"/>
                * 必填项 </td>
            </tr>
            <tr>
              <td height="35" align="right" bgcolor="#FFFFFF" class="line rline"><strong>密码确认</strong> :<br />
                再次输入密码，以此确认!<br /></td>
              <td height="35" bgcolor="#FFFFFF" class="line"><input  name="password2" type="password" class="input"  id="password2"/>
                * 必填项 </td>
            </tr>
            <tr height="28">
              <td width="34%" height="35" align="right" bgcolor="#FFFFFF" class="line rline"><strong>真实姓名：</strong> <br />
                为了方便为您服务，请填写你的联系方式!<br />              </td>
              <td height="35" bgcolor="#FFFFFF" class="line"><input name="true_name"  type="text" class="input" id="true_name" />
                  <span id="nameinfo"></span> * 必填项</td>
            </tr>
            
            <tr>
              <td height="35" align="right" bgcolor="#FFFFFF" class="line rline"><strong>E_mail地址</strong> :<br />
                请输入你的E_mail地址，<br />
                以便找回密码及管理员联系之用!<br /></td>
              <td height="35" bgcolor="#FFFFFF" class="line"><input  name="email"  type="text" class="input" id="email" />
                * 必填项<span id="mailinfo"></span> </td>
            </tr>
            <tr>
              <td height="35" align="right" bgcolor="#FFFFFF" class="line rline"><strong>密码提示问题</strong> :<br />
                请填写，以便找回密码时用!<br /></td>
              <td height="35" bgcolor="#FFFFFF" class="line"><input name="question" type="text" class="input" /></td>
            </tr>
            <tr>
              <td height="35" align="right" bgcolor="#FFFFFF" class="line rline"><strong>密码问题答案</strong> :<br />
                请填写上面问题答案，务必一定要记住! </td>
              <td height="35" bgcolor="#FFFFFF" class="line"><input name="answer" type="text" class="input" />              </td>
            </tr>
          </tbody>
        </table>
            </td>
          </tr>
          <tr>
            <td><img src="images/regbots.gif" width="775" height="70" border="0" usemap="#Map2"></td>
          </tr>
        </table>
       <input type="reset" name="button" id="cmdce" value="重置" style=" display:none;"/>
       <input type="submit" name="button2" id="cmdpost" value="提交" style=" display:none;"/>
        </form>
        <%}else{		
		%>
        <table width="100%" border="0" cellpadding="0" cellspacing="0" style=" background:url(images/regyybj.gif) left repeat-y;">
          <tr>
            <td height="47"><img src="images/regyy.gif" width="775" height="74"></td>
          </tr>
          <tr>
            <td height="356" valign="top"><table width="86%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td height="321" valign="top"><p>请先阅读论坛协议，谢谢！                      <BR>
                  当您申请用户时，表示您已经同意遵守本规章。 </p>
                  <p>欢迎您加入本站点参加交流和讨论，本站点为公共论坛，为维护网上公共秩序和社会稳定，请您自觉遵守以下条款： </p>
                  <p>一、不得利用本站危害国家安全、泄露国家秘密，不得侵犯国家社会集体的和公民的合法权益，不得利用本站制作、复制和传播下列信息：<BR>
                    　   
                    （一）煽动抗拒、破坏宪法和法律、行政法规实施的；<BR>
                    　 
                    （二）煽动颠覆国家政权，推翻社会主义制度的；<BR>
                    　   
                    （三）煽动分裂国家、破坏国家统一的；<BR>
                    　 
                    （四）煽动民族仇恨、民族歧视，破坏民族团结的；<BR>
                    　   
                    （五）捏造或者歪曲事实，散布谣言，扰乱社会秩序的；<BR>
                    　 
                    （六）宣扬封建迷信、淫秽、色情、赌博、暴力、凶杀、恐怖、教唆犯罪的；<BR>
                    　   
                    （七）公然侮辱他人或者捏造事实诽谤他人的，或者进行其他恶意攻击的；<BR>
                    　 
                    （八）损害国家机关信誉的；<BR>
                    　   
                    （九）其他违反宪法和法律行政法规的；<BR>
                    　 
                    （十）进行商业广告行为的。</p>
                  <p>二、互相尊重，对自己的言论和行为负责。<BR>
                    三、禁止在申请用户时使用相关本站的词汇，或是带有侮辱、毁谤、造谣类的或是有其含义的各种语言进行注册用户，否则我们会将其删除。<BR>
                    四、禁止以任何方式对本站进行各种破坏行为。<BR>
                    五、如果您有违反国家相关法律法规的行为，本站概不负责，您的登录论坛信息均被记录无疑，必要时，我们会向相关的国家管理部门提供此类信息。 <BR>
                  </p></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><img src="images/regbot.gif" width="775" height="70" border="0" usemap="#Map"></td>
          </tr>
        </table>
        <%}%>
        <br/>
        <%@ include file="bot.jsp" %> 
      </td>
    </tr>
  </table>
  </div>
 
<map name="Map2">
<area shape="rect" coords="259,42,327,68" style=" cursor:pointer;" href="javascript:;"  onclick="chkfrm('t')">
<area shape="rect" coords="429,41,502,68" style=" cursor:pointer;" href="javascript:;" onClick="chkfrm('f')">
</map>
<map name="Map">
<area shape="rect" coords="259,42,327,68" href="<%=basePath%>register.jsp?step=2">
<area shape="rect" coords="429,41,502,68" href="<%=baseRootPath%>index.jsp">
</map>
<map name="Map3">
<area shape="rect" coords="727,2,762,25" style=" cursor:pointer;"  href="javascript:;"  onclick="window.close();">
</map></body>
</html>
